<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>websocket-user-receive</title>
</head>
<body>

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/stomp.js/2.3.3/stomp.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js"></script>
<script type="text/javascript">
    var noticeSocket = function () {
        // 连接服务器端点
        var s = new SockJS('/wsuser');
        //客户端
        var stompClient = Stomp.over(s);
        stompClient.connect({}, function () {
            console.log("notice socket connected ！");
            // 订阅消息地址
            stompClient.subscribe('/user/queue/customer', function (data) {
                $('#receive').html(data.body);
            });
        });
    };
    noticeSocket();
</script>
<h1><span id="receive">等待接收消息</span></h1>

</body>
</html>